package com.sandy.main;

import java.util.Random;



public class PasswordGenerator implements IGenerator {
	
	public String generate (int length, int digitGoAfterNumOfChars) {
		Random r = new Random ();
		StringBuilder sb = new StringBuilder ();
		for (int i = 0; i <length; i++) {
			char [] charset = 0 == (i + 1)% (digitGoAfterNumOfChars + 1)?  DIGITS : CHARS;

			sb.append (charset [r.nextInt (charset.length)]);
		}
		return sb.toString();
	}
	
	public static final char[] CHARS = { 'a', 'b', 'c', 'd', 'e', 'f', 'g',
		'h', 'i', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v',
		'w', 'x', 'y', 'z', };
	
	public static final char[] DIGITS = { '2', '3', '4', '5', '6', '7', '8',
		'9', };
	
	public String generate () {
		return generate(4,2);
	}

}
